<?php
require_once("tasktypeView.php");
require_once(CORE_DIR.'tasktypeModel.php');

class updateAction extends authAction{

	function __construct(){
		$this->view = new tasktypeView();
	}

	public function run($get, $post, $viewtype) {
		parent::run($get,$post,$viewtype);
		
		$ttModel = new tasktypeModel();		
		
		if (isset($get["id"]) && isset($get["name"]) && isset($get["desc"])){
			$id = $get["id"];
			$tasktypeName = $get["name"];
			$tasktypeDesc = htmlspecialchars($get["desc"], ENT_QUOTES);
			$tasktypeOrderList = explode("|", $get["tasktypeidlist"]);
			
			$affectedRows = $ttModel->updateTaskType($id, $tasktypeName, $tasktypeDesc, $tasktypeOrderList);
			$status = ($affectedRows != -1)? 1: 0;
				
			$this->view->setProperty("status", $status);
			$this->view->setProperty("id", $id);
			$this->view->showUpdateTaskType();
		}
		else{
			$this->view->showBadCmd();
		}	

			
	}
}
?>